home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / dev / mui / urltext.lha / Urltext / Sources / mcc / utils.c < prev   
Encoding:
C/C++ Source or Header  |  2002-01-25  |  1.0 KB  |  62 lines

  1.  
  2. #include "class.h"
  3.  
  4. /****************************************************************************/
  5.  
  6. char ASM
  7. getKeyChar(REG(a0) STRPTR string)
  8. {
  9.     register char res = 0;
  10.  
  11.     if (string)
  12.     {
  13.         register char *c;
  14.  
  15.         for (c = string; *c && *c!='_'; c++);
  16.         if (*c++) res = ToLower(*c);
  17.     }
  18.  
  19.     return res;
  20. }
  21.  
  22. /***********************************************************************/
  23.  
  24. struct stream
  25. {
  26.     char    *buf;
  27.     int     size;
  28.     int     counter;
  29.     int     stop;
  30. };
  31.  
  32. static void ASM
  33. ___stuff(REG(d0) char c,REG(a3) struct stream *s)
  34. {
  35.     if (!s->stop)
  36.     {
  37.         if (++s->counter>=s->size)
  38.         {
  39.             *(s->buf) = 0;
  40.             s->stop   = 1;
  41.         }
  42.         else *(s->buf++) = c;
  43.     }
  44. }
  45.  
  46. int STDARGS
  47. snprintf(char *buf,int size,char *fmt,...)
  48. {
  49.     struct stream s;
  50.  
  51.     s.buf     = buf;
  52.     s.size    = size;
  53.     s.counter = 0;
  54.     s.stop    = 0;
  55.  
  56.     RawDoFmt(fmt,&fmt+1,(APTR)___stuff,&s);
  57.  
  58.     return s.counter-1;
  59. }
  60.  
  61. /****************************************************************************/
  62.